package com.job.ZhangMeng.Homework0714;

import java.util.Random;
import java.util.UUID;

/**
 * 2022.07.14  java.util.Random类
 *              java.util.UUID类
 *              和Math类的“随机”方法
 * 张孟
 */

public class UseRan {

    public static void main(String[] args) {
        Random ran=new Random();
        /*
        for (int i = 0; i < 20 ; i++) {
            System.out.println(ran.nextInt(100)+1);   //Random类的nextInt(int range)方法
                                                        //可以生成并获取一个[0,range)范围内的随机整数
        }
        */

        //给文件起名时,如果想要有唯一的标识,通常会携带一串数字(16进制/32位/36位...)
        String fileName="香香的口味.txt";
        for (int i = 1; i <= 10; i++) {
            String uniqueName=UUID.randomUUID().toString()+fileName;
            System.out.println(uniqueName);
        }

        //Math类有Math.random()方法,但不好用

        String[] names={"viper3","jhin4","王五","老六","clearlove7","gala8"};
        for (int i = 1; i <= 5; i++) {
            System.out.println("第"+i+"个MVP:"+names[ran.nextInt(names.length)]); //数组长度为6,取[0,6)随机下标
        }
    }

}
